﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demo1
{
    class Program
    {
        static void Main(string[] args)
        {
            Udisk UU = new Udisk("金士顿64G");
            Harddisk HH = new Harddisk("三星500G");
            UU.WWW();
            UU.Read();
            UU.Write();
            Console.WriteLine("-------------------------------------------");
            HH.WWW();
            HH.Read();
            HH.Write();
            Console.WriteLine("-------------------------------------------");
            Console.WriteLine();
            Console.WriteLine();
            Computer CC = new Computer("联想电脑");
            CC.Start();
            CC.Usb1 = UU;
            CC.Usb2 = HH;
            CC.WriteData();
            CC.ReadData();
            CC.End();
        }
    }
    class Computer //电脑类
    {
        private string brand;
        private IUSB usb1;
        private IUSB usb2;
        public string Brand { get => brand; set => brand = value; }
        internal IUSB Usb1 { get => usb1; set => usb1 = value; }
        internal IUSB Usb2 { get => usb2; set => usb2 = value; }
        public Computer(string brand) 
        {
            this.brand = brand;
        }
        public Computer() { }
        public void Start()
        {
            Console.WriteLine("{0}正在开机中", this.brand);
        }
        public void ReadData()
        {
            this.usb1.Read();
            this.usb2.Read();
        }
        public void WriteData()
        {
            this.usb1.Write();
            this.usb2.Write();
        }
        public void End()
        {
            Console.WriteLine("{0}正在关机中", this.brand);
        }
    }
    class Disk //移动存储父类
    {
        private string brand;

        public Disk(string brand)
        {
            this.brand = brand;
        }
        public Disk() { }
        public string Brand { get => brand; set => brand = value; }
        public void WWW() 
        {
            Console.WriteLine("你的移动存储器型号为:{0}",this.brand);
        }

    }
    class Udisk : Disk, IUSB //U盘类
    {
        private string brand;
        public Udisk(string brand):base(brand)
        { 

        }
        public Udisk() { }
        public void Read()
        {
            Console.WriteLine("U盘正在读取");
        }

        public void Write()
        {
            Console.WriteLine("U盘正在写入");
        }
    }
    class Harddisk : Disk, IUSB //移动硬盘类
    {
        private string brand;
        public Harddisk(string brand) : base(brand)
        {

        }
        public Harddisk() { }
        public void Read()
        {
            Console.WriteLine("移动硬盘正在读取");
        }

        public void Write()
        {
            Console.WriteLine("移动硬盘正在写入");
        }
    }
    interface IUSB //USB接口
    {
        void Read();
        void Write();
    }
}
